package com.chukun.flink.stream.operator.base;

import org.apache.flink.api.java.tuple.Tuple;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;

/**
 * @author chukun
 * @version 1.0.0
 * @description 视图的操作符
 * @createTime 2022年05月10日 00:06:00
 */
public class ProjectOperator {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStream<Tuple3<String,Integer,String>> dataStream = env.fromCollection(new ArrayList<Tuple3<String,Integer,String>>(){
            {
                add(new Tuple3<>("12300986754",899,"2018-06"));
                add(new Tuple3<>("12300986754",699,"2018-07"));
                add(new Tuple3<>("18800986754",88,"2018-08"));
                add(new Tuple3<>("18800986754",99,"2018-09"));
            }
        });

        DataStream<Tuple2<String,String>> resultStream = dataStream.project(2,0);

        resultStream.print("输出结果");

        // 触发程序执行
        env.execute("project stream");
    }
}
